package com.zzedu.controller;

import com.zzedu.common.annotation.Log;
import com.zzedu.common.core.controller.BaseController;
import com.zzedu.common.core.domain.AjaxResult;
import com.zzedu.common.core.page.TableDataInfo;
import com.zzedu.common.enums.BusinessType;
import com.zzedu.common.utils.ServletUtils;
import com.zzedu.common.utils.poi.ExcelUtil;
import com.zzedu.domain.ZzStuNavicateLog;
import com.zzedu.dto.ZzStuNavicateLogDTO;
import com.zzedu.service.IZzStuNavicateLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * (教育-校区)学生导航阅读记录Controller
 * 
 * @author Mr.Wang
 * @date 2025-07-24
 */
@RestController
@RequestMapping("/school/navice_stu_log")
public class ZzStuNavicateLogController extends BaseController
{
    @Autowired
    private IZzStuNavicateLogService zzStuNavicateLogService;

    /**
     * 查询(教育-校区)学生导航阅读记录列表
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:navice_stu_log:query')")
    @RequestMapping("/list")
    public TableDataInfo list(@RequestBody ZzStuNavicateLogDTO zzStuNavicateLog)
    {
        return getDataTable(zzStuNavicateLogService.page(zzStuNavicateLog.getPageDTO(),zzStuNavicateLogService.buildQuery(zzStuNavicateLog)));
    }

    /**
     * 导出(教育-校区)学生导航阅读记录列表
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:navice_stu_log:export')")
    @Log(title = "(教育-校区)学生导航阅读记录", businessType = BusinessType.EXPORT)
    @RequestMapping("/export")
    public void export(ZzStuNavicateLogDTO zzStuNavicateLog)
    {
        List<ZzStuNavicateLog> list = zzStuNavicateLogService.list(zzStuNavicateLogService.buildQuery(zzStuNavicateLog));
        ExcelUtil<ZzStuNavicateLog> util = new ExcelUtil<ZzStuNavicateLog>(ZzStuNavicateLog.class);
        util.exportExcel(ServletUtils.getResponse(),list, "(教育-校区)学生导航阅读记录数据");
    }




    /**
     * 新增保存(教育-校区)学生导航阅读记录
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:navice_stu_log:add')")
    @Log(title = "(教育-校区)学生导航阅读记录", businessType = BusinessType.INSERT)
    @RequestMapping("/add")
    public AjaxResult addSave(@Validated @RequestBody ZzStuNavicateLog zzStuNavicateLog)
    {
        return toAjax(zzStuNavicateLogService.save(zzStuNavicateLog));
    }



    /**
     * 获取(教育-校区)学生导航阅读记录详细信息
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:navice_stu_log:query')")
    @RequestMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zzStuNavicateLogService.getById(id));
    }


    /**
     * 修改保存(教育-校区)学生导航阅读记录
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:navice_stu_log:edit')")
    @Log(title = "(教育-校区)学生导航阅读记录", businessType = BusinessType.UPDATE)
    @RequestMapping("/edit")
    public AjaxResult editSave(@Validated @RequestBody ZzStuNavicateLog zzStuNavicateLog)
    {
        return toAjax(zzStuNavicateLogService.updateById(zzStuNavicateLog));
    }

    /**
     * 删除(教育-校区)学生导航阅读记录
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:navice_stu_log:remove')")
    @Log(title = "(教育-校区)学生导航阅读记录", businessType = BusinessType.DELETE)
	@RequestMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids)
    {
        return toAjax(zzStuNavicateLogService.removeBatchByIds(ids));
    }
}
